package com.aceleeyy.sevenstar.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

/**
 * 微信授权
 *
 * @auther: Ace Lee
 * @date: 2019/10/27 19:20
 */
public class WXAuthUtil {
//    public static final String APPID = "wx410445f482cc38e8";
    public static final String APPID = "wx9231a7e1050cb202";
//    public static final String APPSECRET = "bbbc1ceaa128a0846480484c8be4831f";
    public static final String APPSECRET = "89457a566f5c1d8c3c85106f37878148";

    public static JSONObject doGetJson(String url) throws ClientProtocolException, IOException {
        JSONObject jsonObject = null;
        DefaultHttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(url);
        HttpResponse response = client.execute(httpGet);
        HttpEntity entity = response.getEntity();
        if (entity != null) {
            //把返回的结果转换为JSON对象
            String result = EntityUtils.toString(entity, "UTF-8");
            jsonObject = JSON.parseObject(result);
        }

        return jsonObject;
    }

}
